<?php
session_start();
$User_ID=$_SESSION['User_ID'];
$first_name=$_SESSION['First_Name'];
$last_name=$_SESSION['Last_Name'];
?>
<?php

require_once("includes/database.php"); 



{	
$page_no = $_GET['page_no'];
$page_no = $page_no+1;
$pet_name = $_GET['pet_name'];
$pet_type = $_GET['pet_type'];
$pet_breed = $_GET['pet_breed'];
$pet_gender = $_GET['pet_gender'];
$pet_birthday = $_GET['pet_birthday'];
$owner_User_ID = $_GET['owner_User_ID'];

date_default_timezone_set ("Asia/Hong_Kong");
$timezone= date_default_timezone_get();

$date =date("Y/m/d");


$tsql="DELETE FROM pet_info_null_db
WHERE Pet_Name='{$pet_name}' and Pet_Type='{$pet_type}' and Pet_Breed='{$pet_breed}' and Pet_Gender='{$pet_gender}' and Pet_Birthday='{$pet_birthday}' and Owner_User_ID='{$owner_User_ID}'";
mysql_query($tsql);
$clientId = mysql_insert_id(); 


$tsql="ALTER TABLE pet_info_null_db DROP Transaction_No";
mysql_query($tsql);
$clientId = mysql_insert_id();


$tsql="ALTER TABLE  `pet_info_null_db` ADD `Transaction_No` INT NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST";
mysql_query($tsql);
$clientId = mysql_insert_id();

$tsql="UPDATE pet_info_db SET Page_No= '{$page_no}', Pet_Vet_User_ID= '{$User_ID}', Pet_Attending_Vet= 'Dr. {$first_name} {$last_name}'
WHERE Pet_Name='{$pet_name}' and Pet_Type='{$pet_type}' and Pet_Breed='{$pet_breed}' and Pet_Gender='{$pet_gender}' and Pet_Birthday='{$pet_birthday}' and Owner_User_ID='{$owner_User_ID}'";






$data =  mysql_query($tsql,$con);

if( $data )
{
        /*echo "Connection established.\n";*/
	 $message = "Adding Patient Successful!";
	 echo "<script type='text/javascript'>alert('$message');window.location = 'thesis_vet_page_add_patient.php?page=1&pet_id=';</script>";
   
}
else
{
  $message = "Adding Patient Failed.!";
	 echo "<script type='text/javascript'>alert('$message');window.location = 'thesis_vet_page_add_patient.php?page=1&pet_id=';</script>";
     die( print_r( mysql_error(), true));
}
}

?>